<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> Options </TITLE>
  <style>
  body {
    margin:10px;
    background: #EBEFF9;
    font-family: arial, sans-serif;
  }
  #header {
    padding-bottom:1em;
    padding-top:1em;
  }
  #header h1 {
    font-size: 30px;
    display:inline;
    color: #3d5d6a;
    padding-bottom:40px;
    padding-left:90px;
    padding-top:70px;
    background:url(icon_48.png) no-repeat;
    background-position:1px 62px;
  }
  h4 {
    padding-left:0.5em;
    border-bottom: 2px dotted #c3c3c3;
    color: #333333;
    line-height: 28px;
    font-size:15px;
  }
  p {
    padding-left:2em;
    font-size:14px;
  }
  .section-header {
    background:#ebeff9;
    border-top:1px solid #b5c7de;
    font-size:99%;
    padding:3px 0 2px 5px;
    font-weight:bold;
    margin-bottom:1em;
    margin-top:1em;
  }
  .contentBox {
    background-color: #ffffff;
    border: 3px solid #bec9ce;
    -webkit-border-radius: 20px 20px;
    padding: 30px;
    text-align: left;
    margin:50px auto 20px auto;
    width: 600px;
  }
  #flashget, #miniFlashget, #thunder,#webThunder, #miniThunder, #chromeDownloader {
    padding:5px 0px 5px 30px;
    line-height:30px;
  }
  #flashget, #miniFlashget {
    background:url(flashget_25.png) no-repeat;
  }
  #thunder, #webThunder, #miniThunder {
    background:url(thunder_25.png) no-repeat;
  }
  #chromeDownloader {
    background:url(default_25.png) no-repeat;
  }
  .closeBtn {
    margin: 20px 0 0 0;
  }
  #footer {
    text-align: center;
    font-size: 13px;
  }
  </style>
 </HEAD>
 <BODY onload="init();">
  <div class="contentBox">
  <div id="header">
    <h1><span id="pageTitle"></span></h1>
  </div>
  <h4 id="downloader"></h4>
  <p id="flashgetDiv"><label><input type="radio" name="downloader" id="radioFlashget"> <span id="flashget">flashget</span></label></p>
  <p id="miniFlashgetDiv"><label><input type="radio" name="downloader" id="radioMiniFlashget"> <span id="miniFlashget">MiniFlashget</span></label></p>
  <p id="thunderDiv"><label><input type="radio" name="downloader" id="radioThunder"> <span id="thunder">thunder</span></label></p>
  <p id="miniThunderDiv"><label><input type="radio" name="downloader" id="radioMiniThunder"> <span id="miniThunder">MiniThunder</span></label></p>
  <p><label><input type="radio" checked="true" name="downloader" id="radioChrome"> <span id="chromeDownloader">chrome</span></label></p>
  <p id="contextMenuItem"><label><input type="checkbox" id="checkboxContextMenu"> <span id="disableMenu"></span></label></p>
  <div class="closeBtn"><button id="saveAndClose" onclick="saveAndClose()"></button></div>
  </div>
  <div id="footer">&copy;2010 Google</div>
  <script>
    var radioFlashget = document.getElementById("radioFlashget");
    var radioMiniFlashget = document.getElementById('radioMiniFlashget');
    var radioThunder = document.getElementById("radioThunder");
    var radioMiniThunder = document.getElementById('radioMiniThunder');
    var radioChrome = document.getElementById("radioChrome");
    var checkboxContextMenu = document.getElementById("checkboxContextMenu");
    bg = chrome.extension.getBackgroundPage();
    function init() {
      i18nReplace("pageTitle");
      i18nReplace("downloader");
      i18nReplace("flashget");
      i18nReplace("miniFlashget");
      i18nReplace("thunder");
      i18nReplace("miniThunder");
      i18nReplace("chromeDownloader");
      i18nReplace("disableMenu");
      i18nReplace('saveAndClose');
      if (bg.useExperimentalAPI) {
        document.getElementById('contextMenuItem').style.display = 'none';
      }
      if (!eval(localStorage.flashget)) {
        document.getElementById('flashgetDiv').style.display = 'none';
      }
      if (!eval(localStorage.miniFlashget)) {
        document.getElementById('miniFlashgetDiv').style.display = 'none';
      }
      if (!eval(localStorage.thunder)) {
        document.getElementById('thunderDiv').style.display = 'none';
      }
      if (!eval(localStorage.miniThunder)) {
        document.getElementById('miniThunderDiv').style.display = 'none';
      }
      if (localStorage.downloader == "flashget") {
        if (eval(localStorage.flashget)) {
          radioFlashget.checked = true;
        }
      } else if (localStorage.downloader == "miniFlashget") {
        if (eval(localStorage.miniFlashget)) {
          radioMiniFlashget.checked = true;
        }
      } else if (localStorage.downloader == "thunder") {
        if (eval(localStorage.thunder)) {
          radioThunder.checked = true;
        }
      } else if (localStorage.downloader == 'miniThunder') {
        if (eval(localStorage.miniThunder)) {
          radioMiniThunder.checked = true;
        }
      }
      if (!eval(localStorage.contextmenu)) {
        checkboxContextMenu.checked = true;
      }

    };

    function saveAndClose() {
      localStorage.downloader =
          (radioFlashget.checked ? 'flashget' : '') ||
          (radioMiniFlashget.checked ? 'miniFlashget' : '') ||
          (radioThunder.checked ? 'thunder' : '') ||
          (radioMiniThunder.checked ? 'miniThunder' : '') ||
          (radioChrome.checked ? 'chromeDownloader' : '');
      localStorage.contextmenu = (checkboxContextMenu.checked ? 'false' : 'true');
      chrome.tabs.getSelected(null, function(tab) {
        chrome.tabs.remove(tab.id);
      });
    };

	function i18nReplace(id) {
	  return document.getElementById(id).innerText = chrome.i18n.getMessage(id);
	};
  </script>
 </BODY>
</HTML>
